#include"wmi_registry.h"

using namespace std;
using namespace log4cxx;
using namespace log4cxx::xml;
using namespace log4cxx::helpers;

WMI_Registry::WMI_Registry(std::wstring name,std::wstring path)
{
	DOMConfigurator::configure("LogConfig.xml");
	_name = name;
	_path = path;
}

WMI_Registry::WMI_Registry(const WMI_Registry& registry)
{
	DOMConfigurator::configure("LogConfig.xml");
	_name = registry._name;
	_path = registry._path;
	_registryList = registry._registryList;
	_valueList = registry._valueList;
}

WMI_Registry::~WMI_Registry(){}

void 
WMI_Registry::addRegistry(WMI_Registry *registry)
{
	_registryList.push_back(registry);
}

void 
WMI_Registry::addValue(WMI_Value& value)
{
	_valueList.push_back(value);
}

WMI_Registry::WMI_Registry()
{	
	
	_name = CONST_HKEY_LOCAL;
	_path = _name;
}

void 
WMI_Registry::print()
{
	wstringstream wout;
	LoggerPtr loggerWRegistry(Logger::getLogger("loggerWRegistry"));

	wout << std::endl << "Registry: "<<std::endl;
	wout << "Name: " << _name<<std::endl;
	wout << "Path: " << _path<<std::endl;
	wout << "Values: " << std::endl;

	LOG4CXX_INFO(loggerWRegistry, wout.str());

	for(int i = 0; i < _valueList.size(); i++)
	{
		wout.str(L"");
		wout << _valueList.at(i).getName() << std::endl;
		LOG4CXX_INFO(loggerWRegistry, wout.str());
	}

	wout.str(L"");
	wout << std::endl << "Childrens:" << std::endl;
	LOG4CXX_INFO(loggerWRegistry, wout.str());
	for(int i = 0; i < _registryList.size(); i++)
	{
		wout.str(L"");
		wout << _registryList.at(i)->_name << std::endl;
		LOG4CXX_INFO(loggerWRegistry, wout.str());
	}
}

WMI_Registry& 
WMI_Registry::operator= (const WMI_Registry& registry)
{

	_name = registry._name;
	_path = registry._path;
	_registryList = registry._registryList;
	_valueList = registry._valueList;

	return *this;
}

